<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>融资租赁公司</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var parentTab_s = parent.liger.get("framecenter");
    function f_addTab_s(tabid, text, url) {
    	parentTab_s.addTabItem({
            tabid: tabid,
            text: text,
            url: url
        });
    };
    $.extend(true, parent.mainApp, {
        parentTab : parentTab_s,
        f_addTab : f_addTab_s
    });
	var grid = null;
	$(function () {
	    $("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/system/sysFlCompInfo/initList.do',
	    	method : 'get',
	        columns: [
	            { display: '全称', name: 'fulNm', minWidth: 140, enabledSort:true },
	            { display: '简称', name: 'shtNm', minWidth: 140, enabledSort:true},
	            { display: '隶属', name: 'compLvlCdNm', minWidth: 140 , enabledSort:true},
	            { display: '状态', name: 'isValidNm', minWidth: 140 , enabledSort:true},
	            { display: '联系人', name: 'lmNm', minWidth: 140 , enabledSort:true},
	            { display: '联系方式', name: 'lmMp', minWidth: 140 , enabledSort:true}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        isScroll: false,
	        checkbox:true,
	        rownumbers:true,
	        onRenderComplete: function () {
	        	//alert("1");
	        	iframeResize ();
	        }
	    });
	    grid = liger.get("ligergrid1");
	
	    $("#searchBar").ligerForm();
	
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         //alert(JSON.stringify(data));
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	
	    $("#pageloading").hide();
	
	});
	
	
	
	//删除数据
	function deleteRecord(){
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length == 0){
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW,SQ_type: "warning"});
			return;
		}
		
		var _ids = [];
		
		for ( var index in selectedRows) {
			_ids.push(selectedRows[index].id);
		}
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/system/sysFlCompInfo/removeByIds.do',
				success:function(msg){
					 if(msg.success == 1){
						 $.ligerDialog.success(msg.info);
						 grid.reload();
					 }else{
						 alert(msg.info);
					 }
				}
			});
		});
	}
	
	//新增数据
	function add(){
		parent.mainApp.f_addTab('Comp_1','新增公司','<%=path%>/system/sysFlCompInfo/toAdd.do')
	}
	

	
	//修改
	function update(){
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length != 1){
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW,SQ_type: "warning"});
			return;
		}
		
		var _id = selectedRows[0].id;
		parent.mainApp.f_addTab('Comp_2','修改公司','<%=path%>/system/sysFlCompInfo/toModifyPage.do?id='+_id);
	}
	
	
	
	//查看数据
	function showDetail(){
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length != 1){
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW,SQ_type: "warning"});
			return;
		}
		
		var _id = selectedRows[0].id;
		parent.mainApp.f_addTab('Comp_3','公司详情','<%=path%>/system/sysFlCompInfo/toDetailPage.do?scpId='+_id);
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
</script>

<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="fieldBox">
                <div class="label">公司名称</div>
                <div class="field">
                    <input name="fulNm" id="fulNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
           
            
            <div class="clearFix"></div>
            <div class="btnsBox">
                <span id="searchBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_1"></i>查询</span>
                <span id="clearBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_18"></i>清空</span>
                <span id="closeBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_13"></i>禁用</span>
                <span id="enableBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_12"></i>启用</span>
                <span id="addBtn" class="sq-button sq-button-hasicon" onclick="add();"><i class="sqBtnIco_3"></i>新增</span>
                <span id="detailBtn" class="sq-button sq-button-hasicon" onclick="showDetail();"><i class="sqBtnIco_2"></i>详情</span>
                <span id="modifyBtn" class="sq-button sq-button-hasicon" onclick="update();"><i class="sqBtnIco_4"></i>修改</span>
                <span id="deleteBtn" class="sq-button sq-button-hasicon" onclick="deleteRecord();"><i class="sqBtnIco_7" ></i>删除</span>
                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
            </div>
        </div>
    </form>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</div>
<script type="text/javascript">
//启用
 $("#enableBtn").click(function(){
	 var selectedRows = grid.getSelectedRows();
		if(selectedRows.length != 1){
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW,SQ_type: "warning"});
			return;
		}
		
	 var id = selectedRows[0].id; 
	
		
		$.ligerDialog.confirm(LogUtils.LOG_CMM_ENABLE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:JSON.stringify(id)},
				url: '<%=path%>/system/sysFlCompInfo/enable.do',
				success:function(msg){
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						 grid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
 });  
//禁用
 $("#closeBtn").click(function(){
	 var selectedRows = grid.getSelectedRows();
		if(selectedRows.length != 1){
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW,SQ_type: "warning"});
			return;
		}
		
	 var id = selectedRows[0].id; 
	
		
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DISABLE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:JSON.stringify(id)},
				url: '<%=path%>/system/sysFlCompInfo/disable.do',
				success:function(msg){
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						 grid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
 }); 
 
 $("#clearBtn").click(function(){
	 $("#resetBtn").click();
 });

</script>
</body>
</html>